/*
 * @Description:
 * @Author: Junhuang
 * @Date: 2022-02-08 11:04:34
 * @LastEditTime: 2022-08-08 16:29:34
 * @LastEditors: Junhuang
 * @Reference: 路由页面
 */
'use strict';


/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, io } = app;
  // 后台用户
  router.post('/admin/login', controller.admin.login);
  router.post('/admin/logout', controller.admin.logout);
  router.get('/admin/user_info', controller.admin.user_info);
  router.get('/admin/list', controller.admin.list);
  router.post('/admin', controller.admin.save);
  router.get('/admin/:id/roles', controller.admin.getRolesByAdmin);
  router.post('/admin/:id/update', controller.admin.update);
  router.post('/admin/:id/enable', controller.admin.enable);
  router.post('/admin/:id/disable', controller.admin.disable);
  router.post('/admin/:id/destroy', controller.admin.destroy);
  router.post('/admin/:id/reset_pwd', controller.admin.resetPassword);
  router.post('/admin/:id/change_pwd', controller.admin.changePassword);
  router.post('/admin/:id/remove_role', controller.admin.removeRole);
  router.get('/admin/:id/check_duplication', controller.admin.isDuplicated);
  router.post('/admin/add_role', controller.admin.addRoleByAdmins);

  router.get('/role/:id/key', controller.role.isRightKey);
  router.get('/role/list', controller.role.list);
  router.get('/role/my', controller.role.myRoles);
  router.get('/role/:id', controller.role.get);
  router.get('/role/:id/adminList', controller.admin.getAdminsByRole);
  router.put('/role/:id', controller.role.update);
  router.delete('/role/:id', controller.role.destroy);
  router.post('/role', controller.role.save);
  router.post('/role/:id/enable', controller.role.enable);
  router.post('/role/:id/disable', controller.role.disable);

  router.post('/test/department/cycle', controller.department.testUpdateCycle);
  router.get('/test/department/fn', controller.department.testFn);
  router.get('/test/department/raw/select', controller.department.testRawSelect);
  router.get('/test/department/raw/update', controller.department.testRawUpdate);
  router.get('/test/department/association', controller.department.testGetAssociation);
  router.get('/test/admin/association', controller.admin.testAdminAssociation);
  router.get('/test/admin_role', controller.admin.testRoleAdmin);
  router.get('/test/add_amdins_to_role', controller.admin.testAddAdminsToRole);

  router.get('/department/tree', controller.department.getTree);
  router.post('/department/:id/refreshPath', controller.department.refreshPath);
  router.post('/department/:id/move', controller.department.departmentMove);
  router.put('/department/:id', controller.department.update);
  router.delete('/department/:id', controller.department.destroy);
  router.post('/department', controller.department.save);

  router.get('/', controller.home.index);
  router.get('/index', controller.home.index);
  router.get('/bad', controller.home.bad);
  // router.get('/test', controller.home.test);
  router.get('/cate/:cate_id/video/:page', controller.home.cate_page);

  // 用户相关
  router.post('/reg', controller.user.reg);
  router.post('/login', controller.user.login);
  router.post('/logout', controller.user.logout);
  router.post('/user/follow', controller.user.follow);
  router.post('/user/unfollow', controller.user.unfollow);
  router.get('/user/followed', controller.user.isFollowed);
  router.get('/user/follows/:page', controller.user.follows);
  router.get('/user/fans/:page', controller.user.fans);
  router.get('/user/statistics', controller.user.statistics);
  router.get('/user/user_info', controller.user.user_info);
  router.post('/user/fan_drop', controller.user.dropFan);
  router.put('/user/:id/password', controller.user.password);
  router.put('/user/:id/info', controller.user.info);

  // 用户相关-后台
  router.get('/user/list', controller.user.list);
  router.post('/user/:id/status', controller.user.changeStatus);

  // 目录相关
  router.get('/category/:category_id/video/:page', controller.video.list);
  router.get('/category', controller.category.index);


  // 作品(video)相关
  router.post('/video/destroy', controller.video.del);
  router.get('/video/:id/edit', controller.video.edit);
  router.post('/video', controller.video.save);
  router.post('/video/:id', controller.video.update);
  router.get('/video_search/:page', controller.video.search);
  // 获取作品详细信息
  router.get('/video_read/:id', controller.video.read);
  router.get('/video_read_auth/:id', controller.video.read_auth);

  // 获取作品基本信息
  router.get('/video_get/:id', controller.video.get);

  // 作品相关-后台
  router.get('/video/list', controller.video.videoListPage);
  router.post('/video/:id/status', controller.video.changeStatus);

  // upload
  router.post('/upload', controller.file.upload);
  router.get('/cos_auth', controller.file.geCOSAuth);

  // 指定用户的作品列表
  router.get('/video_list/:page', controller.video.index);

  // 注意videoDetail的驼峰式写法
  router.get('/video_detail_list', controller.videoDetail.index);
  router.post('/video_detail', controller.videoDetail.save);
  // 注意/video_detail/destroy 与 动态路由/video_detail/:id 形式相似，因此要写到动态路由前面
  router.post('/video_detail/destroy', controller.videoDetail.destroy);
  router.get('/video_detail/list', controller.videoDetail.list);
  router.post('/video_detail/:id', controller.videoDetail.update);
  router.post('/video_detail/:id/status', controller.videoDetail.changeStatus);

  // vod
  router.post('/vod/sign', controller.vod.sign);

  // 收藏
  router.post('/fava', controller.fava.fava);
  router.post('/unfava', controller.fava.unfava);
  router.get('/fava_list/:page', controller.fava.list);


  // 评论
  router.post('/comment', controller.comment.save);
  router.post('/comment/:id/status', controller.comment.changeStatus);
  router.get('/comment/list', controller.comment.list);
  router.get('/video_comment/:video_id', controller.comment.comment);
  router.get('/video_comment_auth/:video_id', controller.comment.comment_auth);

  // 推荐位
  router.get('/advertisement/list', controller.advertisement.list);
  router.post('/advertisement/:id/status', controller.advertisement.changeStatus);
  router.get('/advertisement_list/:page', controller.advertisement.index);
  router.put('/advertisement/:id', controller.advertisement.update);
  router.post('/advertisement', controller.advertisement.save);


  // 计划
  router.get('/plan_list', controller.plan.index);
  router.get('/user_plans/:page', controller.plan.getPlansPage);
  router.get('/plan/:id/get', controller.plan.get);
  router.get('/plan_week', controller.plan.week_list);
  router.get('/plan_students', controller.plan.getStudentsPlan);
  router.put('/plan/:id/video', controller.plan.updateVideo);
  router.post('/plan_update', controller.plan.save);
  router.put('/plan/:id/advice', controller.plan.advice);

  // 排行
  router.get('/rank_list', controller.rank.index);

  // 礼物
  router.get('/gift_list', controller.gift.index);
  router.get('/gift_list_page', controller.gift.listPage);

  // 订单
  router.get('/order_list', controller.order.index);

  // 直播间
  router.get('/live_list/:page', controller.live.list);
  router.get('/live_list', controller.live.index);
  router.post('/live/create', controller.live.save);
  router.get('/live/:id', controller.live.read);
  router.post('/live/:id/config', controller.live.changeLiveConfig);
  router.post('/live/:id/status', controller.live.changeStatus);

  // 直播间用户
  router.get('/live_user_list', controller.liveUser.index);

  // 直播间礼物
  router.get('/live_gift_list', controller.liveGift.index);


  // 直播间弹幕
  router.get('/live_danmu_list', controller.liveDanmu.index);

  // 404
  router.all('*', controller.home.err404);

  // socket
  io.of('/').route('joinLive', io.controller.nsp.joinLive);
  io.of('/').route('leaveLive', io.controller.nsp.leaveLive);
  io.of('/').route('comment', io.controller.nsp.comment);
  io.of('/').route('gift', io.controller.nsp.gift);
  io.of('/').route('stmp', io.controller.nsp.reStmp);
};
